$(document).ready(function(){
	getUserList();
})

function getUserList() {
	var url = '/json?action=QUERY_T_SYSTEM_USERBY_PAGER_ACTION';
	$UI.changePage(url,10,'T_SYSTEM_USER','#list',printRes,'#page','<tr><td colspan="4">暂无数据</td></tr>');
}

function printRes(obj,result,i,n,total,current){
	var trStr = [
		'<tr '+ (i%2 == 0 ? "" : "class=\'alt\'") +'>',
		'<td><input type="checkbox" value="'+obj.SYSTEM_USER_ID+'" name="SYSTEM_USER_ID" /></td>',
		'<td>'+ obj.LOGIN_NAME +'</td>',
		'<td>'+ (obj.EMAIL == '' ? '无' :  obj.EMAIL) +'</td>',
		'<td>',
		'<a href="'+ adminPath + '/system/update_user.html?menu=sys_manage&tab=user_list&id='+obj.SYSTEM_USER_ID+'&current_page='+ current +'"><img src="../images/icons/icon_edit.png" alt="修改" /></a> ',
		'<a href="javascript:deleteUser('+obj.SYSTEM_USER_ID+','+current+')"><img src="../images/icons/icon_delete.png" alt="删除" /></a>',
		'</td>',
		'</tr>'
	].join('');
	$(result).append(trStr);
}

function deleteUser(id, current){
	if(!confirm("确定删除？")){
		return;
	}
	var url = '/json?action=DELETE_T_SYSTEM_USER_ACTION&SYSTEM_USER_ID=' + id;
	$.post(url,{},function(data){
		if(data.success){
			location.href = adminPath + '/system/user_list.html?menu=sys_manage&tab=user_list&current_page=' + current;
		}
		else{
			alert(data.errors.errmsg);
		}
	},'json');
}